package com.song.JavaThread_day02.ch2_8;

import java.util.Random;

public class FileMock {
	
	private String content[];
	private int index;
	public FileMock(int size, int length) {
		content = new String[size];
		Random random = new Random();
		for(int i=0;i<size ; i++)
		{
			StringBuilder sb = new StringBuilder();
			for(int j = 0; j<length;j++)
			{
				int indice = (int)random.nextInt(255);
				sb.append(indice+"");
			}
			content[i] = sb.toString();
//			System.out.println(content[i]);
		}
		index =0 ;
	}
	
	public synchronized boolean hasMoreLines()
	{
		return index <content.length;
	}
	
	public synchronized String getLine()
	{
		if(this.hasMoreLines())
		{
			System.out.println(" Mock :" +index );
			return content[index++];
		}
		return null;
	}
	
}
